<%@ page language="java" import="java.util.*, org.apache.commons.lang3.StringUtils,com.zjut.an.news.manager.*, com.zjut.an.news.dao.*, 
com.zjut.an.acquisitionhistory.dao.*,com.zjut.an.acquisitionhistory.manager.*,com.zjut.zs.pay.dao.*, com.zjut.zs.pay.manager.*,
com.zjut.zs.user.manager.*, com.zjut.zs.user.dao.*,com.zjut.zs.userstatus.manager.*, com.zjut.zs.userstatus.dao.*,com.zjut.zs.applyview.manager.*, com.zjut.zs.applyview.dao.*,
com.zjut.an.webclass.manager.*, com.zjut.an.webclass.dao.*,com.zjut.an.util.tools.*,com.zjut.zs.util.tools.*,com.zjut.an.util.system.*,
com.zjut.an.config.manager.*, com.zjut.an.config.dao.*" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">  
<meta name="renderer" content="webkit"> 
<title>无标题文档</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/web.css" rel="stylesheet" type="text/css" />
</head>
<body>
<%
if (session.getAttribute("zsUser") == null&&session.getAttribute("admin") == null) {
	out.print("<script>alert('由于长时间未操作，系统已经自动注销，请重新登陆');</script>");
	out.print("<script>top.window.location='main.jsp';</script>");
} else {

AnConfigManager anconfig = (AnConfigManager) SpringContextUtil.getBean("AnConfigManager");
ZsHTMLCreat html = (ZsHTMLCreat) SpringContextUtil.getBean("ZsHTMLCreat");
ZsUserManager umanager = (ZsUserManager) SpringContextUtil.getBean("ZsUserManager");
ZsUserStatusManager zsmanager = (ZsUserStatusManager) SpringContextUtil.getBean("ZsUserStatusManager");
AnAcquisitionHistoryManager acmanager = (AnAcquisitionHistoryManager) SpringContextUtil.getBean("AnAcquisitionHistoryManager");
ZsApplyViewManager amanager = (ZsApplyViewManager) SpringContextUtil.getBean("ZsApplyViewManager");
ZsPayManager pmanager = (ZsPayManager) SpringContextUtil.getBean("ZsPayManager");
ZsUser user = null;
ZsApplyView appview = null;
if(session.getAttribute("admin")!=null && request.getParameter("usId")!=null) {
	String usId = request.getParameter("usId");
	user = umanager.getData(usId);
} else if (session.getAttribute("zsUser")!=null) {
	user = (ZsUser)session.getAttribute("zsUser");	
}	
if (user!=null) {
	appview = amanager.getData(user.getUsId());
}

ZsUserStatus userstatus = zsmanager.getDataByUser(user);

 %>
	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="index.jsp">首页</a></li>
    <li><a href="#">面试抽签</a></li>
    </ul>
    </div>
    <div class="formbody">    
	    <div class="rightinfo">		    
			<!--单页面-->  
			<%
			String testno = "";
			//从抽签编号里取出第一个抽签号码
			if(Status.PAYSTATUS_YES.getStatus().equals(userstatus.getPayStatus())) {
				if (null==userstatus.getTestNo()||userstatus.getTestNo().trim().length()==0) {
					ZsPay pay = new ZsPay();
					pay.setUsIdcard(userstatus.getUsIdcard());
				    List list = pmanager.getDataByInstance(1,1,null,null,pay).getObjects();

					if (list.size()>0) {
						pay = (ZsPay)list.get(0);
						AnAcquisitionHistory anac = new AnAcquisitionHistory();
						anac.setNeId(pay.getPayId());
						anac.setAcId(userstatus.getZsUser().getUsId());
						anac.setChannelUrl("抽签编号");
						//anac.setDescription("cq");
						//抽签的专业在这里修改
						anac.setDescription(appview.getInZymc01());
						anac.setContentUrl(userstatus.getUsIdcard());
						acmanager.saveHistory(anac);
						int place = acmanager.getDataPlaceById(anac)-1;
					
						//取出抽签编号
						//String cq = html.getJsonValue("cq");
						//在config中配置appview.getInZymc01()的抽签序列
						String cq = html.getJsonValue(appview.getInZymc01());
						List<String> nums = Arrays.asList(cq.split(","));
						//取出编号中该位置编号
						testno = nums.get(place).toString();
						
						userstatus.setTestNo(testno);
						zsmanager.updateData(userstatus);
					}
				} 
				out.print("你的抽签号为："+userstatus.getTestNo());
			} else {
				out.print("缴费后进行抽签");
			}			
			
			 %>
	    </div> 
    </div>
    
<%} %>
</body>

</html>
